# This Makefile.am is in the public domain
ACLOCAL_AMFLAGS = -I m4
SUBDIRS = contrib m4 src .
DIST_SUBDIRS = $(SUBDIRS) po
EXTRA_PO_DIST = po/ABOUT-NLS $(top_srcdir)/po/configure.ac po/configure
W32COMMON = w32/common/gen_dll_res.ps1 w32/common/microhttpd_dll_res_vc.rc.in w32/common/microhttpd_dll_res_vc.rc \
  w32/common/MHD_config.h w32/common/vs_dirs.props w32/common/common-build-settings.vcxproj \
  w32/common/libmicrohttpd-build-settings.vcxproj w32/common/libmicrohttpd-files.vcxproj w32/common/libmicrohttpd-filters.vcxproj \
  w32/common/hellobrowser-files.vcxproj w32/common/hellobrowser-filters.vcxproj \
  w32/common/apps-build-settings.vcxproj
W32VS2013 = w32/VS2013/libmicrohttpd.vcxproj w32/VS2013/libmicrohttpd.vcxproj.filters \
  w32/VS2013/hellobrowser.vcxproj w32/VS2013/hellobrowser.vcxproj.filters \
  w32/VS2013/simplepost.vcxproj w32/VS2013/largepost.vcxproj \
  w32/VS2013/libmicrohttpd.sln
W32VS2015 = w32/VS2015/libmicrohttpd.vcxproj w32/VS2015/libmicrohttpd.vcxproj.filters \
  w32/VS2015/hellobrowser.vcxproj w32/VS2015/hellobrowser.vcxproj.filters \
  w32/VS2015/simplepost.vcxproj w32/VS2015/largepost.vcxproj \
  w32/VS2015/libmicrohttpd.sln
W32VS2017 = w32/VS2017/libmicrohttpd.vcxproj w32/VS2017/libmicrohttpd.vcxproj.filters \
  w32/VS2017/hellobrowser.vcxproj w32/VS2017/hellobrowser.vcxproj.filters \
  w32/VS2017/simplepost.vcxproj w32/VS2017/largepost.vcxproj \
  w32/VS2017/libmicrohttpd.sln
EXTRA_DIST = \
  acinclude.m4 \
  libmicrohttpd.pc.in \
  $(EXTRA_PO_DIST) \
  $(W32COMMON) $(W32VS2013) $(W32VS2015) $(W32VS2017)

pkgconfigdir = $(libdir)/pkgconfig
pkgconfig_DATA = libmicrohttpd.pc

if BUILD_DOC
SUBDIRS += doc
endif

.PHONY: po-files update-po-files po-files-pre-distdir renew-po-configure.ac update-POTFILES.in

# Do not override automake rule, only add prerequisite
distdir@EMPTY_VAR@: po-files-pre-distdir

# Do not override automake rule, only add prerequisite
distclean-recursive@EMPTY_VAR@: po/Makefile

srcdir_po = $(top_srcdir)/po

# Test target: build main po file
po-files: $(srcdir_po)/libmicrohttpd.pot

# Test target: force update all po files
update-po-files: po-files-pre-distdir Makefile
	@$(am__cd) po && $(MAKE) $(AM_MAKEFLAGS) libmicrohttpd.pot-update

# Update po-related files before make distdir
po-files-pre-distdir: update-POTFILES.in renew-po-configure.ac
	@$(MAKE) $(AM_MAKEFLAGS) po/Makefile

# Clean in po directory only if po/Makefile was generated to avoid
# useless generation of po/Makefile only for 'clean' target
clean-local:
	@ if test -f po/Makefile; then \
	    $(MAKE) $(AM_MAKEFLAGS) po/Makefile && \
	    $(am__cd) po && $(MAKE) $(AM_MAKEFLAGS) clean || exit 1; \
	  fi;

po/Makefile: $(srcdir_po)/Makefile.in.in $(srcdir_po)/Makevars $(srcdir_po)/POTFILES.in po/config.status
	@$(am__cd) po && @SHELL@ ./config.status ./Makefile.in po-directories

po/configargs.stamp:
	@$(MAKE) $(AM_MAKEFLAGS) $(top_builddir)/config.status && \
	  @SHELL@ ./config.status po/configargs.stamp

# Regenerate po/config.status if 'po/configure' was updated or 'configure' parameters was changed
po/config.status: $(srcdir_po)/configure po/configargs.stamp
	@$(MKDIR_P) po && $(am__cd) po && echo "cd po && @SHELL@ ./configure @ac_configure_args@" && \
	  @SHELL@ $(abs_top_srcdir)/po/configure @ac_configure_args@ --srcdir=$(abs_top_srcdir)/po \
	    --disable-option-checking --no-create --no-recursion

# Next rules actually create files in source tree, not in build tree, but those files should
# stay in source tree and should be distributed in tarball, i.e. should not be created during
# normal builds.
$(srcdir_po)/libmicrohttpd.pot: po/Makefile
	@$(am__cd) po && $(MAKE) $(AM_MAKEFLAGS) libmicrohttpd.pot

# This target doesn't depend on po/configure.acT so po/configure.ac (and po/configure) will not be
# forced to regenerate after each run of main configure.
# If po/configure.ac is missing - it will be generated.
$(srcdir_po)/configure.ac:
	@$(MAKE) $(AM_MAKEFLAGS) renew-po-configure.ac

# Update po/configure.ac only if po/configure.acT (generated by main configure) is different.
# If po/configure.ac is unchanged then po/configure will not be regenerated
renew-po-configure.ac:
	@$(MAKE) $(AM_MAKEFLAGS) po/configure.acT && \
	  if ! test -f $(srcdir_po)/configure.ac || \
	     ! cmp -s po/configure.acT $(srcdir_po)/configure.ac ; then \
	    echo "cp po/configure.acT $(srcdir_po)/configure.ac" && \
	    cp po/configure.acT $(srcdir_po)/configure.ac || exit 1; \
	  fi

$(srcdir_po)/configure: $(srcdir_po)/configure.ac
	@$(am__cd) $(srcdir_po) && echo "Creating po/configure..." && \
	  echo "@ACLOCAL@" && @ACLOCAL@ && \
	  echo "@AUTOCONF@" && @AUTOCONF@

# Generate po/POTFILES.in if po/POTFILES.in is missing
$(srcdir_po)/POTFILES.in:
	@$(MAKE) $(AM_MAKEFLAGS) update-POTFILES.in

update-POTFILES.in:
	@$(am__cd) $(srcdir_po) && echo @ECHO_N@ "Creating po/POTFILES.in... @ECHO_C@" && chmod o+w . && \
	  find '../src/include' ! -name 'include' -prune -name '*.h' ! -name 'mhd_options.h' > POTFILES.in && \
	  find '../src/microhttpd' ! -name 'microhttpd' -prune \( -name '*.h' -o -name '*.c' \) ! -name 'test_*' >> POTFILES.in && \
	  echo "@ECHO_T@done." || (rm -f POTFILES.in ; echo "@ECHO_T@failed." && false)
